package com.example.demo.base.permission.controller;


import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.domain.entity.PermissionFrontUrl;
import com.example.demo.dto.ResponseDto;
import com.example.demo.param.PersionParam;
import com.example.demo.param.RolePersionParam;
import com.example.demo.service.PermissionFrontUrlService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/perssion")
@RestController
public class PermissionController {

    @Autowired
    PermissionFrontUrlService permissionFrontUrlService;

    /**
     * 权限列表返回：
     * 再创建角色的时候，需要勾选能访问的前端页面，此功能就是返回权限列表的
     * @param persionParam
     * @return
     */
    @PostMapping("/queryPerssion")
    ResponseDto queryPerssion(@RequestBody PersionParam persionParam){
        Page<PermissionFrontUrl> permissionFrontUrlPage = permissionFrontUrlService.queryAllPermissionFrontUrl(persionParam);
        return new ResponseDto<>().buildSucceedHasData(permissionFrontUrlPage);
    }


    /**
     * 权限列表返回：
     * 根据角色，查询角色拥有的权限，后续修改，查看角色权限时使用
     * @param rolePersionParam
     * @return
     */
    @PostMapping("/queryRolePermission")
    ResponseDto queryRolePermission(@RequestBody RolePersionParam rolePersionParam){
        return new ResponseDto<>().buildSucceedHasData(permissionFrontUrlService.queryRolePermission(rolePersionParam));
    }





}
